package com.redis.controller;

import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.redisson.api.listener.MessageListener;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
@RestController
public class TopicController {


    @Resource
    private RedissonClient redissonClient;

    @RequestMapping(value = "/topicclients")
    public void topic(){
        RTopic<String> topic = redissonClient.getTopic("anyTopic");
        long clientsReceivedMessage = topic.publish(new String("1111111111111111111"));

        System.out.println(clientsReceivedMessage);
    }

//    @RequestMapping(value = "/topiccListener")
//    public void Listener(){
//        RTopic<String> topic = redissonClient.getTopic("anyTopic");
//        topic.addListener((channel, msg) -> System.out.println(msg));
//    }
}
